package com.note.common.domain;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.persistence.Column;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.format.annotation.DateTimeFormat;

import java.time.LocalDateTime;

/**
 * 评论实体类
 * 对应数据库comment表，存储用户对笔记的评论
 */
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("comment")
@Schema(description = "评论实体")
public class Comment extends BaseEntity {

    /**
     * 评论ID
     */
    @TableId(value = "id", type = IdType.AUTO)
    @Schema(description = "评论ID", example = "1")
    private Long id;

    /**
     * 所属笔记ID
     */
    @TableField("note_id")
    @Schema(description = "所属笔记ID", example = "1")
    private Long noteId;

    /**
     * 评论用户ID
     */
    @TableField("user_id")
    @Schema(description = "评论用户ID", example = "1")
    private Long userId;

    /**
     * 评论内容
     */
    @TableField("content")
    @Schema(description = "评论内容", example = "这是一条评论")
    private String content;


    @TableField
    @Schema(description = "删除标记 0:正常 1:删除", example = "0")
    private Integer deleted = 0;

    @Column(name = "created_at")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") // 修正月份MM和小时HH的大小写
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") // 修正时区写法
    @TableField(value = "created_at", fill = FieldFill.INSERT)
    @Schema(description = "创建时间", example = "2023-10-01T12:00:00")
    private LocalDateTime createdAt;

    @Column(name = "updated_at")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") // 修正月份MM和小时HH的大小写
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") // 修正时区写法
    @TableField(value = "updated_at", fill = FieldFill.INSERT_UPDATE)
    @Schema(description = "更新时间", example = "2023-10-01T12:00:00")
    private LocalDateTime updatedAt;
} 